<?php
class ModelShippingSpeedy extends Model {
	public function createTables() {
		$this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "speedy_address` (
		  `address_id` INT(11) NOT NULL,
		  `customer_id` INT(11) NOT NULL,
		  `postcode` VARCHAR(10) NOT NULL DEFAULT '',
		  `city` VARCHAR(255) NOT NULL DEFAULT '',
		  `city_id` INT(11) NOT NULL DEFAULT '0',
		  `city_nomenclature` VARCHAR(15) NOT NULL DEFAULT '',
		  `to_office` TINYINT(1) NOT NULL DEFAULT '0',
		  `office_id` INT(11) NOT NULL DEFAULT '0',
		  `quarter` VARCHAR(255) NOT NULL DEFAULT '',
		  `quarter_id` INT(11) NOT NULL DEFAULT '0',
		  `street` VARCHAR(255) NOT NULL DEFAULT '',
		  `street_id` INT(11) NOT NULL DEFAULT '0',
		  `street_no` VARCHAR(255) NOT NULL DEFAULT '',
		  `block_no` VARCHAR(255) NOT NULL DEFAULT '',
		  `entrance_no` VARCHAR(255) NOT NULL DEFAULT '',
		  `floor_no` VARCHAR(255) NOT NULL DEFAULT '',
		  `apartment_no` VARCHAR(255) NOT NULL DEFAULT '',
		  `note` VARCHAR(255) NOT NULL DEFAULT '',
		  KEY `address_id` (`address_id`),
		  KEY `customer_id` (`customer_id`)
		) ENGINE=MyISAM DEFAULT CHARSET=utf8");

		$this->db->query("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "speedy_order` (
		  `speedy_order_id` INT(11) NOT NULL AUTO_INCREMENT,
		  `order_id` INT(11) NOT NULL DEFAULT '0',
		  `bol_id` VARCHAR(15) NOT NULL,
		  `data` TEXT NOT NULL,
		  `date_created` DATETIME NOT NULL,
		  `courier` TINYINT(1) NOT NULL DEFAULT '0',
		  PRIMARY KEY (`speedy_order_id`),
		  KEY `order_id` (`order_id`)
		) ENGINE=MyISAM DEFAULT CHARSET=utf8");
	}

	public function deleteTables() {
		$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "speedy_address`");
		$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "speedy_order`");
	}
}
?>